home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Micromail 103 / MicroMail.jar / MessageDetails.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-09-07  |  3.2 KB  |  89 lines

  1. import javax.microedition.lcdui.Command;
  2. import javax.microedition.lcdui.CommandListener;
  3. import javax.microedition.lcdui.Displayable;
  4. import javax.microedition.lcdui.Form;
  5.  
  6. public class MessageDetails extends Form implements CommandListener {
  7.    private MicroMail midlet;
  8.    private MessageList parent;
  9.    private int activeBoxId;
  10.    private int activeMsgId;
  11.    private Message message;
  12.    Command backCommand = new Command(Resource.getText(1), 2, 6);
  13.    Command editCommand = new Command(Resource.getText(5), 1, 1);
  14.    Command replyCommand = new Command(Resource.getText(6), 1, 2);
  15.    Command deleteCommand = new Command(Resource.getText(3), 1, 3);
  16.    Command markunreadCommand = new Command(Resource.getText(8), 1, 5);
  17.  
  18.    public MessageDetails(MicroMail var1, MessageList var2, int var3, int var4) {
  19.       super(Resource.getText(25));
  20.       this.midlet = var1;
  21.       this.parent = var2;
  22.       this.activeBoxId = var3;
  23.       this.activeMsgId = var4;
  24.       this.message = MicroCache.getMessage(this.activeBoxId, this.activeMsgId);
  25.       ((Displayable)this).setCommandListener(this);
  26.       ((Displayable)this).addCommand(this.backCommand);
  27.       if (this.activeBoxId == 2) {
  28.          ((Displayable)this).addCommand(this.editCommand);
  29.       }
  30.  
  31.       if (this.activeBoxId == 1) {
  32.          ((Displayable)this).addCommand(this.replyCommand);
  33.       }
  34.  
  35.       ((Displayable)this).addCommand(this.deleteCommand);
  36.       ((Displayable)this).addCommand(this.markunreadCommand);
  37.       this.displayMessage();
  38.       MicroCache.markRead(this.activeBoxId, this.message, this.activeMsgId, true);
  39.       this.parent.updateItem(this.activeMsgId, this.message.subject, true);
  40.    }
  41.  
  42.    public void commandAction(Command var1, Displayable var2) {
  43.       if (var1 == this.backCommand) {
  44.          MicroMail.display.setCurrent(this.parent);
  45.       } else if (var1 == this.editCommand) {
  46.          MessageForm var3 = new MessageForm(this.midlet, this.parent, this.message, this.activeMsgId);
  47.          MicroMail.display.setCurrent(var3);
  48.       } else if (var1 == this.replyCommand) {
  49.          String var5 = this.message.to;
  50.          if (this.message.replyTo != null && this.message.replyTo.length() > 0) {
  51.             this.message.to = this.message.replyTo;
  52.          } else {
  53.             this.message.to = this.message.from;
  54.          }
  55.  
  56.          this.message.from = var5;
  57.          this.message.body = "";
  58.          this.message.ID = -1;
  59.          MessageForm var4 = new MessageForm(this.midlet, this, this.message, -1);
  60.          MicroMail.display.setCurrent(var4);
  61.       } else if (var1 == this.deleteCommand) {
  62.          MicroCache.deleteMessage(this.activeBoxId, this.activeMsgId, this.message);
  63.          this.parent.deleteItem(this.activeMsgId);
  64.          MicroMail.display.setCurrent(this.parent);
  65.       } else if (var1 == this.markunreadCommand) {
  66.          MicroCache.markRead(this.activeBoxId, this.message, this.activeMsgId, false);
  67.          this.parent.updateItem(this.activeMsgId, this.message.subject, false);
  68.          MicroMail.display.setCurrent(this.parent);
  69.       }
  70.  
  71.       MicroMail.dispose(this);
  72.    }
  73.  
  74.    public void displayMessage() {
  75.       if (this.activeBoxId != 1 && this.activeBoxId != 4) {
  76.          ((Form)this).append(Resource.getText(26) + this.message.to + "\r\n");
  77.          ((Form)this).append(Resource.getText(29) + this.message.subject + "\r\n");
  78.          ((Form)this).append(Resource.getText(30) + this.message.body + "\r\n");
  79.       } else {
  80.          ((Form)this).append(Resource.getText(27) + this.message.from + "\r");
  81.          ((Form)this).append(Resource.getText(26) + this.message.to + "\r");
  82.          ((Form)this).append(Resource.getText(28) + this.message.date + "\r");
  83.          ((Form)this).append(Resource.getText(29) + this.message.subject + "\r");
  84.          ((Form)this).append(Resource.getText(30) + this.message.body + "\r");
  85.       }
  86.  
  87.    }
  88. }
  89.